function hideAll(obj) {
	var div = $("#function > div");
	for(var i in div) {
		if(div[i].nodeName == "DIV") {
			if(div[i].getAttribute('id') != obj) {
				div[i].style.display = "none";
			}
		}
	}
}

function service() {
	hideAll("service");
	var options = {};	
	$( "#service" ).toggle( "blind", options, 500 );
}

function product() {
	hideAll("product");
	var options = {};	 
	$( "#product" ).toggle( "size", options, 500 );
}

function group() {
	hideAll("group");
	var options = {};	 
	$( "#group" ).toggle( "fold", options, 1000 );
}

function connect() {
	hideAll("connect");
	var options = {};	 
	$( "#connect" ).toggle( "blind", options, 1000 );
}

function campus() {
	hideAll("campus");
	var options = {};	 
	$( "#campus" ).toggle( "drop", options, 1000 );
}

function where() {
	hideAll("where");
	$( "#where" ).toggle();
}

/* 工作团队 */
$(function () {
  $(".items .img").hover(function (e) {
    var _this  = $(this), //闭包
        _desc  = _this.find(".desc").stop(true),
        width  = _this.width(), //取得元素宽
        height = _this.height(), //取得元素高
        left   = e.offsetX || e.originalEvent.layerX, //得到左边界
        top    = e.offsetY || e.originalEvent.layerY, //得到上边界
        right  = width - left, //计算出右边界
        bottom = height - top, //计算出下边界
        rect   = {}, //坐标对象，用于执行对应方法。
        _min   = Math.min(left, top, right, bottom), //得到最小值
        _out   = e.type == "mouseleave", //是否是离开事件
        spos   = {}; //起始位置

    rect[left] = function (epos) { //鼠从标左侧进入和离开事件
      spos = {"left": -width, "top": 0};
      if (_out) {
        _desc.animate(spos, "fast"); //从左侧离开
      } else {
        _desc.css(spos).animate(epos, "fast"); //从左侧进入
      }
    };

    rect[top] = function (epos) { //鼠从标上边界进入和离开事件
      spos = {"top": -height, "left": 0};
      if (_out) {
        _desc.animate(spos, "fast"); //从上面离开
      } else {
        _desc.css(spos).animate(epos, "fast"); //从上面进入
      }
    };

    rect[right] = function (epos) { //鼠从标右侧进入和离开事件
      spos = {"left": left,"top": 0};
      if (_out) {
        _desc.animate(spos, "fast"); //从右侧成离开
      } else {
         _desc.css(spos).animate(epos, "fast"); //从右侧进入
      }
    };
    
    rect[bottom] = function (epos) { //鼠从标下边界进入和离开事件
      spos = {"top": height, "left": 0};
      if (_out) {
        _desc.animate(spos, "fast"); //从底部离开
      } else {
        _desc.css(spos).animate(epos, "fast"); //从底部进入
      }
    };

    rect[_min]({"left":0, "top":0}); // 执行对应边界 进入/离开 的方法
  });
});